package com.toKnow.model.vo;

import com.toKnow.model.entity.Article;
import com.toKnow.model.entity.Tag;
import com.toKnow.model.entity.Type;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class ArticleVo {
    private String article_id;
    private String title;
    private Integer author_id;
    private String author_name;
    private String avatar;
    private Date upload_date;
    private Boolean original;
    private String content;
    private String file;
    private String cover;
    private String digest;

    @Override
    public String toString() {
        return "ArticleVo{" +
            "article_id='" + article_id + '\'' +
            ", title='" + title + '\'' +
            ", author_id=" + author_id +
            ", author_name='" + author_name + '\'' +
            ", avatar='" + avatar + '\'' +
            ", upload_date=" + upload_date +
            ", original=" + original +
            ", content='" + content + '\'' +
            ", file='" + file + '\'' +
            ", cover='" + cover + '\'' +
            ", digest='" + digest + '\'' +
            ", read_times=" + read_times +
            ", like_times=" + like_times +
            ", collect_times=" + collect_times +
            ", comment_times=" + comment_times +
            ", type=" + type +
            ", tag=" + tag +
            ", is_like=" + is_like +
            ", is_collect=" + is_collect +
            ", is_Buy=" + is_Buy +
            '}';
    }

    public ArticleVo(String article_id, String title, Integer author_id, String author_name, String avatar, Date upload_date, Boolean original, String content, String file, String cover, String digest, Integer read_times, Integer like_times, Integer collect_times, Integer comment_times, List<String> type, List<String> tag, Boolean is_like, Boolean is_collect, Boolean is_Buy) {
        this.article_id = article_id;
        this.title = title;
        this.author_id = author_id;
        this.author_name = author_name;
        this.avatar = avatar;
        this.upload_date = upload_date;
        this.original = original;
        this.content = content;
        this.file = file;
        this.cover = cover;
        this.digest = digest;
        this.read_times = read_times;
        this.like_times = like_times;
        this.collect_times = collect_times;
        this.comment_times = comment_times;
        this.type = type;
        this.tag = tag;
        this.is_like = is_like;
        this.is_collect = is_collect;
        this.is_Buy = is_Buy;
    }

    public String getDigest() {
        return digest;
    }

    public void setDigest(String digest) {
        this.digest = digest;
    }

    private Integer read_times;
    private Integer like_times;
    private Integer collect_times;
    private Integer comment_times;
    private List<String> type=new ArrayList<>();
    private List<String> tag=new ArrayList<>();
    private Boolean is_like;
    private Boolean is_collect;
    private Boolean is_Buy;

    public ArticleVo(String article_id, String title, Integer author_id, String author_name, String avatar, Date upload_date, Boolean original, String content, String file, String cover, Integer read_times, Integer like_times, Integer collect_times, Integer comment_times, List<String> type, List<String> tag, Boolean is_like, Boolean is_collect, Boolean is_Buy) {
        this.article_id = article_id;
        this.title = title;
        this.author_id = author_id;
        this.author_name = author_name;
        this.avatar = avatar;
        this.upload_date = upload_date;
        this.original = original;
        this.content = content;
        this.file = file;
        this.cover = cover;
        this.read_times = read_times;
        this.like_times = like_times;
        this.collect_times = collect_times;
        this.comment_times = comment_times;
        this.type = type;
        this.tag = tag;
        this.is_like = is_like;
        this.is_collect = is_collect;
        this.is_Buy = is_Buy;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getArticle_id() {
        return article_id;
    }

    public void setArticle_id(String article_id) {
        this.article_id = article_id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Integer getAuthor_id() {
        return author_id;
    }

    public void setAuthor_id(Integer author_id) {
        this.author_id = author_id;
    }

    public String getAuthor_name() {
        return author_name;
    }

    public void setAuthor_name(String author_name) {
        this.author_name = author_name;
    }

    public Date getUpload_date() {
        return upload_date;
    }

    public void setUpload_date(Date upload_date) {
        this.upload_date = upload_date;
    }

    public Boolean getOriginal() {
        return original;
    }

    public void setOriginal(Boolean original) {
        this.original = original;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getFile() {
        return file;
    }

    public void setFile(String file) {
        this.file = file;
    }

    public Integer getRead_times() {
        return read_times;
    }

    public void setRead_times(Integer read_times) {
        this.read_times = read_times;
    }

    public Integer getLike_times() {
        return like_times;
    }

    public void setLike_times(Integer like_times) {
        this.like_times = like_times;
    }

    public Integer getCollect_times() {
        return collect_times;
    }

    public void setCollect_times(Integer collect_times) {
        this.collect_times = collect_times;
    }

    public Integer getComment_times() {
        return comment_times;
    }

    public void setComment_times(Integer comment_times) {
        this.comment_times = comment_times;
    }

    public List<String> getType() {
        return type;
    }

    public void setType(List<String> type) {
        this.type = type;
    }

    public List<String> getTag() {
        return tag;
    }

    public void setTag(List<String> tag) {
        this.tag = tag;
    }

    public Boolean getIs_like() {
        return is_like;
    }

    public void setIs_like(Boolean is_like) {
        this.is_like = is_like;
    }

    public Boolean getIs_collect() {
        return is_collect;
    }

    public void setIs_collect(Boolean is_collect) {
        this.is_collect = is_collect;
    }

    public Boolean getIs_Buy() {
        return is_Buy;
    }

    public void setIs_Buy(Boolean is_Buy) {
        this.is_Buy = is_Buy;
    }

    public ArticleVo() {
    }

    public ArticleVo(String article_id, String title, Integer author_id, String author_name, Date upload_date, Boolean original, String content, String file, Integer read_times, Integer like_times, Integer collect_times, Integer comment_times, List<String> type, List<String> tag, Boolean is_like, Boolean is_collect, Boolean is_Buy) {
        this.article_id = article_id;
        this.title = title;
        this.author_id = author_id;
        this.author_name = author_name;
        this.upload_date = upload_date;
        this.original = original;
        this.content = content;
        this.file = file;
        this.read_times = read_times;
        this.like_times = like_times;
        this.collect_times = collect_times;
        this.comment_times = comment_times;
        this.type = type;
        this.tag = tag;
        this.is_like = is_like;
        this.is_collect = is_collect;
        this.is_Buy = is_Buy;
    }

    public ArticleVo(Article article){
        this.article_id = String.valueOf(article.getId());
        this.title = article.getTitle();
        this.author_id = article.getAuthorId();
        this.author_name = article.getAuthorName();
        this.upload_date = article.getPublishDate();
        this.original = article.getOrigin();
        this.content = article.getContent();
        this.file = article.getAttachment();
        this.cover = article.getCover();
        this.digest = article.getDigest();
        this.read_times = article.getReadNumber();
        this.like_times = article.getLikeNumber();
        this.collect_times = article.getCollectNumber();
        this.comment_times = article.getCommentNumber();
        this.avatar=article.getAvatar();
        for (Tag tag : article.getTagList()){
            this.tag.add(tag.getName());
        }
        for (Type type : article.getTypeList()){
            this.type.add(type.getName());
        }
    }
}
